--- title: Valid Covid Certificates in Austria author: Sophie Steininger date: '2021-12-05' ---
###Libraries
pacman::p_load(tidyverse, leaflet, sf, htmlwidgets, spdep)
##Read in the Vaccination data
vac_data_intro <- read_delim("COVID19_vaccination_municipalities.csv", delim = ";")
## Rows: 2117 Columns: 9
## -- Column specification --------------------------------------------------------
## Delimiter: ";"
## chr (1): municipality_name
## dbl (7): municipality_id, municipality_population, dose_1, dose_2, dose_3, ...
## dttm (1): date
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
##Geo Data
new_geo_dat <- st_read("C:/Users/sophi/Documents/Dokumente final/UNI AKTUELLES/Economic and Social Policy - Data Science/Github HW/GeoJSON-TopoJSON-Austria/2021/simplified-95/gemeinden_95_geo.json")
## Reading layer `gemeinden_95_korr' from data source
## `C:\Users\sophi\Documents\Dokumente final\UNI AKTUELLES\Economic and Social Policy - Data Science\Github HW\GeoJSON-TopoJSON-Austria\2021\simplified-95\gemeinden_95_geo.json'
## using driver `GeoJSON'
## Simple feature collection with 2118 features and 2 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 9.527906 ymin: 46.37302 xmax: 17.15787 ymax: 49.02116
## Geodetic CRS: WGS 84
##Transform and merge Data
tansformated <- vac_data_intro %>%
mutate("iso" = as.character(municipality_id))
vac_data <- new_geo_dat %>%
full_join(tansformated, by = "iso")
##Bundesländer Data
new_geo_dat_laender <- st_read("C:/Users/sophi/Documents/Dokumente final/UNI AKTUELLES/Economic and Social Policy - Data Science/Github HW/GeoJSON-TopoJSON-Austria/2021/simplified-95/laender_95_geo.json")
## Reading layer `laender_95_geo' from data source
## `C:\Users\sophi\Documents\Dokumente final\UNI AKTUELLES\Economic and Social Policy - Data Science\Github HW\GeoJSON-TopoJSON-Austria\2021\simplified-95\laender_95_geo.json'
## using driver `GeoJSON'
## Simple feature collection with 9 features and 2 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 9.527906 ymin: 46.37302 xmax: 17.15787 ymax: 49.02116
## Geodetic CRS: WGS 84
#valid_percent_certificates
quantiles <- round(quantile(vac_data$valid_certificates_percent, na.rm = TRUE))
pal <- colorBin("Greens",
domain = vac_data$valid_certificates_percent,
bins = quantiles)
m <- leaflet(vac_data) %>%
addProviderTiles("CartoDB") %>%
setView(lat = 47.367538, lng = 13.436292, zoom = 6) %>%
addPolygons(
fillColor = ~pal(valid_certificates_percent),
opacity = 0.2,
weight = 0.5,
color = "Black",
fillOpacity = 0.7,
group = "Valid_Certificates_Percent",
popup = ~paste0("<b>", name, "</b>",
"<br/>", valid_certificates_percent, n = 2),
highlightOptions = highlightOptions(
weight = 1,
color = "red",
bringToFront = TRUE)) %>%
addLegend(position = "topright",
pal = pal,
values = quantiles,
title = "% of Valid Certificates",
group = "Valid_Certificates_Percent") %>%
addPolygons(
data = new_geo_dat_laender,
color = "black",
weight = 1,
fill = FALSE)
m